﻿<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <!--作为公共模版分离出去-->
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="admin/images/rookieCs.ico" />
    <link rel="Shortcut Icon" href="admin/images/rookieCs.ico" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui/css/H-ui.my.css" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/css/h-ui.admin.pro.iframe.min.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/Hui-iconfont/1.0.9/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/lc_switch/20160127/css/lc_switch.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/layui/2.5.6/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="admin/css/iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="admin/css/mywork.css" />
    <script type="text/javascript" src="admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="admin/lib/layer/3.1.1/layer.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/plugins/datagrid-detailview.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="admin/lib/lc_switch/20160127/js/lc_switch.min.js"></script>
    <script type="text/javascript" src="admin/lib/layui/2.5.6/layui.js"></script>
    <script>document.write('<script type="text/javascript" src="admin/js/common.js?v='+ Date.now() +'"><\/script>');</script>
    <script>document.write('<script type="text/javascript" src="admin/js/formatter.js?v='+ Date.now() +'"><\/script>');</script>
    <!--作为公共模版分离出去-->
    <title>我的付款申请</title>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%;font-family: 微软雅黑,serif" memuId="payment-self">
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en" style="float: none">&gt;</span> 付款管理
    <span class="c-gray en" style="float: none">&gt;</span> 我的付款申请
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div data-options="region:'center', border:false">
    <!--按钮元素-->
    <div id="buttonInfo" style="padding: 2px 0px 2px 5px; background-color: #F5FAFE;">
        <button class="easyui-linkbutton" onclick="query(pageParam, true)"><i class="Hui-iconfont">&#xe665;</i>查询</button>
        <button class="easyui-linkbutton" onclick="editPayment()"><i class="Hui-iconfont">&#xe6df;</i>修改</button>
        <button class="easyui-linkbutton" onclick="delPayment()"><i class="Hui-iconfont">&#xe6e2;</i>删除</button>
    </div>
    <!--表格元素-->
    <div id="tableInfo"></div>
</div>
<div data-options="region:'east', title:'查询条件', hideCollapsedContent:false, collapsible:true, collapsed:true" style="width:250px">
    <!--查询条件元素-->
    <form id="searchFormInfo" style="display: none">
        <div class="searchLabel">客户品牌：<input id="s_customerBrand" name="customerBrand"/></div>
        <div class="searchLabel">媒体名称：<input id="s_mediumName" name="mediumName"/></div>
        <div class="searchLabel"><input id="s_numberType" name="numberType" /><input id="s_numberStart" name="numberStart" />-<input id="s_numberEnd" name="numberEnd" /></div>
        <div class="searchLabel"><input id="s_dateType" name="dateType" /><input id="s_dateStart" name="dateStart" />-<input id="s_dateEnd" name="dateEnd" /></div>
        <div class="searchLabel">投放位置：<input id="s_putAddress" name="putAddress"/></div>
        <div class="searchLabel">付款账户：<input id="s_payAccount" name="payAccount"/></div>
        <div class="searchLabel">收方名称：<input id="s_recName" name="recName"/></div>
        <div class="searchLabel">状态：<input id="s_status" name="status"/></div>
    </form>
</div>
<script type="text/javascript">
    //准备函数
    $(function () {
        initSearchForm();
        initGrid();
        getGridHidden("tableInfo");
        query(pageParam);
    });

    //查询条件初始化
    function initSearchForm() {
        $("#s_customerBrand").textbox({
            width: 160
        });
        $("#s_mediumName").textbox({
            width: 160
        });
        $("#s_numberType").combobox({
            width: 220,
            panelHeight: "auto",
            valueField: "value",
            textField: "text",
            data: [{value:1, text:"付款金额", selected:true}, {value:2, text:"执行价"}, {value:3, text:"成本价"}]
        });
        $("#s_numberStart").numberbox({
            width: 108
        });
        $("#s_numberEnd").numberbox({
            width: 108
        });
        $("#s_dateType").combobox({
            width: 220,
            panelHeight: "auto",
            valueField: "value",
            textField: "text",
            data: [{value:1, text:"申请日期", selected:true}, {value:2, text:"审核日期"}, {value:3, text:"付款日期"}, {value:4, text:"投放日期"}]
        });
        $("#s_dateStart").datebox({
            width: 108,
            editable: false
        });
        $("#s_dateEnd").datebox({
            width: 108,
            editable: false
        });
        $("#s_putAddress").combobox({
            width: 160,
            panelHeight: "auto",
            valueField: "text",
            data: orderPutAddressDataAll
        });
        $("#s_payAccount").combobox({
            width: 160,
            panelHeight: "auto",
            valueField: "text",
            editable: true,
            data: [{text:"全部", selected:true}, {text:"私账"}, {text:"公账"}]
        });
        $("#s_recName").textbox({
            width: 160
        });
        $("#s_status").combobox({
            width: 185,
            panelHeight: "auto",
            editable: false,
            data: paymentStatusDataAll
        });
        $("#searchFormInfo").show();
    }

    //表格元素初始化
    function initGrid() {
        $("#tableInfo").datagrid({
            pagination: true,
            singleSelect: true,
            fitColumns: false,
            striped: true,
            fit: true,
            frozenColumns: [[
                {field: "ck", checkbox: "true"},
                {field: "id", title: "付款编号", width: 70, align: "center", sortable: true, formatter: paymentIdFormatter},
                {field: "orderId", title: "排期编号", width: 70, align: "center", sortable: true},
                {field: "customerBrand", title: "客户品牌", width: 100, align: "center", sortable: true},
                {field: "mediumName", title: "媒体名称", width: 120, align: "center", sortable: true},
                {field: "mediumType", title: "媒体类型", width: 70, align: "center", sortable: true, formatter: mediumTypeFormatter},
                {field: "putDate", title: "投放日期", width: 90, align: "center", sortable: true, formatter: dateFormatter},
                {field: "putAddress", title: "投放位置", width: 80, align: "center", sortable: true}
            ]],
            columns: [[
                {field: "quotedPrice", title: "执行价", width: 80, align: "center", sortable: true, formatter: orderQuotedPriceFormatter},
                {field: "costPrice", title: "成本价", width: 80, align: "center", sortable: true, formatter: orderCostPriceFormatter},
                {field: "payAccount", title: "付款账户", width: 100, align: "center", sortable: true},
                {field: "payMoney", title: "付款金额", width: 100, align: "center", sortable: true, formatter: paymentPayMoneyFormatter},
                {field: "recName", title: "收方名称", width: 150, align: "center", sortable: true},
                {field: "recAccount", title: "收方账号", width: 150, align: "center", sortable: true},
                {field: "recBank", title: "收方开户行", width: 150, align: "center", sortable: true},
                {field: "createUserId", title: "申请人", width: 80, align: "center", sortable: true, formatter: createUserIdFormatter},
                {field: "createDate", title: "申请时间", width: 140, align: "center", sortable: true, formatter: dateTimeFormatter},
                {field: "createDesc", title: "申请事由", width: 150, align: "left", sortable: false, formatter: remarkFormatter},
                {field: "auditUserName", title: "审核人", width: 80, align: "center", sortable: true},
                {field: "auditDate", title: "审核时间", width: 140, align: "center", sortable: true, formatter: dateTimeFormatter},
                {field: "payUserName", title: "支付人", width: 80, align: "center", sortable: true},
                {field: "payDate", title: "支付时间", width: 140, align: "center", sortable: true, formatter: dateTimeFormatter},
                {field: "mediumUserName", title: "对接媒介", width: 80, align: "center", sortable: true},
                {field: "orderUserName", title: "对接销售", width: 80, align: "center", sortable: true},
                {field: "status", title: "状态", width: 80, align: "center", sortable: true, formatter: paymentStatusFormatter}
            ]],
            toolbar: ".breadcrumb, #buttonInfo, #searchInfo",
            pageNumber: pageParam.pageNo,
            pageSize: pageParam.pageSize,
            pageList: Page.getPageList(),
            onSortColumn: function (orderBy, sortBy) {
                pageParam.pageNo = 1;
                pageParam.orderBy = orderBy;
                pageParam.sortBy = sortBy;
                query(pageParam);
            },
            onSelect: function() {
                selectedTableRow();
            },
            onUnselect: function() {
                selectedTableRow();
            },
            onSelectAll: function() {
                selectedTableRow();
            },
            onUnselectAll: function() {
                selectedTableRow();
            },
            onLoadSuccess: function () {
                toolBarBtnDisabledById([false, true, true], "buttonInfo");
            }
        }).datagrid("getPager").pagination({
            buttons: [
                {text: "个性化设置", iconCls: "icon-tip", handler: function() {selectColumnMenu("tableInfo");}}
            ],
            onSelectPage: function(pageNumber, pageSize) {
                pageParam.pageNo = pageNumber;
                pageParam.pageSize = pageSize;
                query(pageParam);
            },
            onChangePageSize: function(pageSize) {
                pageParam.pageSize = pageSize;
            }
        });
        //表格事件
        var selectedTableRow = function() {
            var selectRow = $("#tableInfo").datagrid("getSelections");
            if (selectRow.length === 0) {
                toolBarBtnDisabledById([false, true, true], "buttonInfo");
            } else if (selectRow.length === 1) {
                toolBarBtnDisabledById([false, false, false], "buttonInfo");
            } else {
                toolBarBtnDisabledById([false, true, false], "buttonInfo");
            }
        };
    }

    //分页查询
    function query(pageParam, goHead) {
        pageParam.condition = getFormJson($("#searchFormInfo"));
        if (goHead && goHead)
            pageParam.pageNo = 1;
        ajaxGetFun("payment/querySelfPaymentPage", pageParam, function(bizData) {
            $("#tableInfo").datagrid("loadData", bizData.rowList);
            $("#tableInfo").datagrid("getPager").pagination({pageNumber: bizData.pageNo, total: bizData.total});
        }, null, "获取我的付款申请列表");
    }

    //修改
    function editPayment() {
        var selectRows = $("#tableInfo").datagrid("getSelections");
        if (selectRows.length !== 1) {
            return showWarnMsg("请选择一条条目后操作");
        }
        openIframe(false, 500, 500, "payment-info.html", function() {
            $("iframe")[0].contentWindow.$("#formInfo").form("load", selectRows[0]);
            ajaxGetFun("payment/listPaymentByOrderId", {orderId: selectRows[0].orderId}, function(bizData) {
                var html = "";
                for (var i in bizData) {
                    if (bizData[i].status === 1) {
                        html += dates("Y-m-d H:i:s", bizData[i].createDate) + " <b>" + bizData[i].createUserName + "</b> 申请付款金额：" + bizData[i].payMoney +" <b>待审核</b><br/>";
                    } else if (bizData[i].status === 3) {
                        html += dates("Y-m-d H:i:s", bizData[i].createDate) + " <b>" + bizData[i].createUserName + "</b> 申请付款金额：" + bizData[i].payMoney +" <b>审核通过</b><br/>";
                    } else if (bizData[i].status === 4) {
                        html += dates("Y-m-d H:i:s", bizData[i].createDate) + " <b>" + bizData[i].createUserName + "</b> 申请付款金额：" + bizData[i].payMoney +" <b>支付完成</b><br/>";
                    }
                }
                $("iframe")[0].contentWindow.$("#payRecord").html(html);
            }, null, "获取排期付款记录");
        }, function(index, layero) {
            var formEle = layero.find("iframe")[0].contentWindow.$("#formInfo");
            if (formEle.form("validate")) {
                ajaxPostFun("payment/updatePaymentInfo", getFormJson(formEle), function() {
                    layer.close(index);
                    query(pageParam, true);
                    showSuccessMsg("修改成功");
                }, null, "修改付款申请");
            }
        });
    }

    //删除
    function delPayment() {
        var selectRows = $("#tableInfo").datagrid("getSelections");
        if (selectRows.length === 0) {
            return showWarnMsg("请选择条目后操作");
        }
        layer.confirm("确认要删除选中的付款申请吗？", function() {
            ajaxPostFun("payment/deletePaymentInfoByIds", {ids: mergedRowCell(selectRows, "id")}, function(bizData) {
                showSuccessMsg("已删除"+ bizData +"条数据");
                query(pageParam, true);
            }, null, "删除付款申请");
        });
    }
</script> 
</body>
</html>